package com.xyu.Service;
import com.xyu.po.User;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;
@Service
public class RabbitMqListenerService {
 @RabbitListener(queues = "fanout_queue_email")
 public void psubConsumerEmail(Message message) {
 byte[] body = message.getBody();
 String s = new String(body);
 System.out.println("邮件业务接收到消息： "+s);
 }
 @RabbitListener(queues = "fanout_queue_sms")
 public void psubConsumerSms(Message message) {
  byte[] body = message.getBody();
  String s = new String(body);
  System.out.println("短信业务接收到消息： " + s);
 }
 @RabbitListener(bindings =@QueueBinding(value =
 @Queue("fanout_queue_tem"), exchange =
 @Exchange(value = "exchange_my"
         ,type = "fanout")))
 public void psubConsumerEmailAno(User user) {
  System.out.println("1邮件业务接收到消息： "+user);
 }
 @RabbitListener(bindings =@QueueBinding(value =
 @Queue("fanout_queue_num"),exchange =
 @Exchange(value = "exchange_my"
         ,type = "fanout")))
 public void psubConsumerSmsAno(User user) {
  System.out.println("1短信业务接收到消息： "+user);
 }
 @RabbitListener(
         bindings = @QueueBinding(
                 value = @Queue(name = "routing_queue_all"),
                 exchange = @Exchange(value = "routing_exchange", type = "direct"),
                 key = "error_routing_key")
 )
 public void routingConsumerError(String message) {
  System.out.println("接收到error级别日志消息： " + message);
 }
 @RabbitListener(bindings =@QueueBinding(value =
 @Queue("topic_queue_email"),exchange =
 @Exchange(value = "topic_exchange"
         ,type = "topic"),
         key = "info.#.sms.#"))
 public void topicConsumerSms(String message) {
  System.out.println("接收到短信订阅需求处理消息： "+message);
 }
}
